//
//  MGTableView.m
//  Express
//
//  Created by lhongl on 2025/9/25.
//  Copyright © 2025 QM. All rights reserved.
//

#import "MGTableView.h"

@implementation MGTableView

- (instancetype)init {
    if(self = [super init]){
        [self initeTablView];
    }
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style{
    if(self = [super initWithFrame:frame style:style]){
      [self initeTablView];
    }
    return self;
}

#pragma mark 初始化
- (void)initeTablView {
    if (@available(iOS 15.0, *)) {
        self.sectionHeaderTopPadding = 0;
    }

    self.backgroundColor = [UIColor clearColor];
    self.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    self.separatorColor = [UIColor colorWithRed:169.0 green:169.0 blue:169.0 alpha:1.0];
    self.separatorInset = UIEdgeInsetsMake(0, 12, 0, 12 );
    self.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;

    self.estimatedSectionFooterHeight = CGFLOAT_MIN;
    self.sectionFooterHeight = CGFLOAT_MIN;

    self.estimatedSectionHeaderHeight = CGFLOAT_MIN;
    self.sectionHeaderHeight = CGFLOAT_MIN;

    self.showsHorizontalScrollIndicator = NO;
    self.showsVerticalScrollIndicator = NO;

    CGSize size = [UIScreen mainScreen].bounds.size;
    self.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, size.width, CGFLOAT_MIN)];
    self.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, size.height, CGFLOAT_MIN)];
}

#pragma mark 设置
- (void)setShowSeparator:(BOOL)showSeparator{
    _showSeparator = showSeparator;
    if (showSeparator == NO) {
        self.separatorStyle = UITableViewCellSeparatorStyleNone;
        return;
    }
    self.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
}

- (void)setMg_estimatedRowHeight:(CGFloat)mg_estimatedRowHeight{
    _mg_estimatedRowHeight = mg_estimatedRowHeight;
    self.estimatedRowHeight = mg_estimatedRowHeight;
    self.rowHeight = UITableViewAutomaticDimension;
}

- (void)setMg_estimatedSectionFooterHeight:(CGFloat)mg_estimatedSectionFooterHeight {
    _mg_estimatedSectionFooterHeight = mg_estimatedSectionFooterHeight;
    self.estimatedSectionFooterHeight = mg_estimatedSectionFooterHeight;
    self.sectionFooterHeight = UITableViewAutomaticDimension;
}

- (void)setMg_estimatedSectionHeaderHeight:(CGFloat)mg_estimatedSectionHeaderHeight{
    _mg_estimatedSectionHeaderHeight = mg_estimatedSectionHeaderHeight;
    self.estimatedSectionHeaderHeight = mg_estimatedSectionHeaderHeight;
    self.sectionHeaderHeight = UITableViewAutomaticDimension;
}



/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
